/*
 * #%L
 * java model
 * %%
 * Copyright (C) 2009 - 2011 prefabware.com Stefan Isele
 * %%
 * All Rights Reserved.
 * This program is dual-licensed under the GNU General Public license
 * or a commercial license.
 * You may select to use one or the other of these licenses.
 * To obtain a commercial license please contact Stefan Isele at www.stefan-isele.de
 * Any modifications to this file must keep this entire header intact.
 * Redistribution, except as permitted by the selected license, is prohibited.
 * #L%
 */
package com.prefabware.jmodel;

import java.util.ArrayList;
import java.util.List;

import com.prefabware.commons.QualifiedName;


public class JMethodSignature {
	private List<JArgument> arguments;
	private QualifiedName name;
	 public JMethodSignature(QualifiedName name) {
		 this.name=name;
		this.arguments=new ArrayList<JArgument>();
	}

	@Override
	public String toString() {
		return "JMethodSignature [name=" + name + ", arguments=" + arguments
				+ "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((arguments == null) ? 0 : arguments.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		JMethodSignature other = (JMethodSignature) obj;
		if (arguments == null) {
			if (other.arguments != null)
				return false;
		} else if (!arguments.equals(other.arguments))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	public boolean add(JArgument e) {
		return arguments.add(e);
	}


	public List<JArgument> getArguments() {
		return arguments;
	}

	public String getArgumentsSeperatedBy(String parmPrefix,String separator) {
		StringBuffer result=new StringBuffer();
		String prepend="";
		for (JArgument param : this.arguments) {
			result.append(prepend);
			result.append(parmPrefix);
			result.append(param);
			prepend=separator;
		}
		return result.toString();
	}

}
